<template>
	<div class="content-box">
		<div v-if="loadCover">
			<div class="tabs ">
				<div class="tab__top--div PingFangSC-Semibold flex justify-between pl-30 pr-30">
					<div class="item" v-for="(item, i) in typeList" :key="i" @click="tabClick(item, i)">
						<div :class="{ 'curr': tabIndex == i, 'font-bold': brandModel == '三星' }">
							{{ item.label
							}}</div>

					</div>
				</div>
			</div>
			<div class="listBox ml-20 mr-20 pt-100">
				<div v-for="(item, index) in list" :key="index" class="bg-fff p-24 bor-r16 mt-20"
					@click="goDetail(item)">
					<div class="fontS28 font-bold">{{ item.professionName }}</div>
					<div class="flex-center justify-between fontS24 color-6d mt-20 bor-b pb-20">
						<div>{{ item.experienceRequireName || '' }}</div>
						<div>|</div>
						<div>{{ item.minEducationName || '' }}</div>
						<div>|</div>
						<div>{{ item.salary || '' }}</div>
						<div>|</div>
						<div>{{ item.postTypeName || '' }}</div>
						<div>|</div>
						<div>{{ item.cityName || '' }}</div>
					</div>
					<div class="mt-20 flex justify-between">
						<div class="flex flex-direction align-center justify-center">
							<div class="fontS32 font-500">{{ item.viewCnt }}</div>
							<div class="mt-20">看过我</div>
						</div>
						<div class="flex flex-direction align-center justify-center">
							<div class="fontS32 font-500">{{ item.chatCnt }}</div>
							<div class="mt-20">沟通过</div>
						</div>
						<div class="flex flex-direction align-center justify-center">
							<div class="fontS32 font-500">{{ item.resumeCnt }}</div>
							<div class="mt-20">收到简历</div>
						</div>
					</div>


				</div>
				<div class="lh-120 text-center fontS28 color-6d" v-if="loadList">正在加载中...</div>
				<div class="lh-120 text-center fontS28 color-6d" v-if="!noteFlag && !loadNo && !loadList">没有更多数据</div>
				<without v-if="loadNo"></without>
			</div>
		</div>
	</div>

</template>
<script>
import { appCompanyPostList } from '@/api/index'


export default {
	data() {
		return {
			baseUrl: getApp().globalData.baseUrl,
			loadCover: false,
			tabIndex: 0,
			tabName: '全部',
			typeList: [{
				value: 1,
				label: '招聘中',
			},
			{
				value: 0,
				label: '待发布',
			},
			{
				value: 2,
				label: '审核失败',
			},
			{
				value: 3,
				label: '已关闭',
			},
			],
			queryForm: {

				pageNum: 1,
				pageSize: 10,
				companyId: '',


			},
			list: [],
			noteFlag: true,
			loadList: false,
			loadNo: false
		};
	},
	computed: {
		userInfo() {
			return this.$store.getters.userInfo || {};
		},
	},
	async onLoad(opt) {
		this.queryForm.companyId = this.userInfo.companyId || ''
		await this.getList()
	},

	onReachBottom() {
		this.loadList = true
		this.queryForm.pageNum++;
		if (this.noteFlag) {
			this.getList();
		} else {
			this.loadList = false
		}
	},
	methods: {
		async getList() {
			this.noteFlag = true
			this.loadNo = false
			this.loadList = false
			const { rows } = await appCompanyPostList(this.queryForm)
			if (rows.length < this.queryForm.pageSize) {
				this.noteFlag = false
			}
			if (this.queryForm.pageNum === 1) {
				this.list = rows
			} else {
				this.list = [...this.list, ...rows]
			}
			this.loadCover = true

			if (this.queryForm.pageNum === 1 && this.list.length < 1) {
				this.loadNo = true
			}
		},
		async getLogin() {
			const { data } = await api.checkLogin.checkLogin()
			this.loginStatus = data.loginStatus
		},
		cancelOrder(item) {
			uni.showModal({
				content: '是否确定取消订单？',
				success: res => {
					if (res.confirm) {
						cancelOrderNew({ orderId: item.orderNo }).then(res => {
							this.getData();
						})
					}
				},
				fail: () => { },
				complete: () => { }
			});
		},
		goDetail(item) {
			uni.navigateTo({
				url: `/pages/position/detail?positionId=${item.id}&type=zhaopin`
			})
		},
		tabClick(item, index) {
			this.tabIndex = index

			this.queryForm.status = item.value
			this.queryForm.pageNum = 1
			this.getList()

		},
	}
};
</script>
<style lang="less" scoped>
@import url(hire.less);
</style>
